package com.docker.ywx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.docker.common.annotation.Log;
import com.docker.common.core.controller.BaseController;
import com.docker.common.core.domain.AjaxResult;
import com.docker.common.enums.BusinessType;
import com.docker.ywx.domain.DoctorMedicalrecord;
import com.docker.ywx.service.IDoctorMedicalrecordService;
import com.docker.common.utils.poi.ExcelUtil;
import com.docker.common.core.page.TableDataInfo;

/**
 * 病历模版Controller
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/ywx/medicalrecord")
public class DoctorMedicalrecordController extends BaseController
{
    @Autowired
    private IDoctorMedicalrecordService doctorMedicalrecordService;

    /**
     * 查询病历模版列表
     */
    @PreAuthorize("@ss.hasPermi('ywx:medicalrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorMedicalrecord doctorMedicalrecord)
    {
        startPage();
        List<DoctorMedicalrecord> list = doctorMedicalrecordService.selectDoctorMedicalrecordList(doctorMedicalrecord);
        return getDataTable(list);
    }

    /**
     * 导出病历模版列表
     */
    @PreAuthorize("@ss.hasPermi('ywx:medicalrecord:export')")
    @Log(title = "病历模版", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoctorMedicalrecord doctorMedicalrecord)
    {
        List<DoctorMedicalrecord> list = doctorMedicalrecordService.selectDoctorMedicalrecordList(doctorMedicalrecord);
        ExcelUtil<DoctorMedicalrecord> util = new ExcelUtil<DoctorMedicalrecord>(DoctorMedicalrecord.class);
        util.exportExcel(response, list, "病历模版数据");
    }

    /**
     * 获取病历模版详细信息
     */
    @PreAuthorize("@ss.hasPermi('ywx:medicalrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doctorMedicalrecordService.selectDoctorMedicalrecordById(id));
    }

    /**
     * 新增病历模版
     */
    @PreAuthorize("@ss.hasPermi('ywx:medicalrecord:add')")
    @Log(title = "病历模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorMedicalrecord doctorMedicalrecord)
    {
        return toAjax(doctorMedicalrecordService.insertDoctorMedicalrecord(doctorMedicalrecord));
    }

    /**
     * 修改病历模版
     */
    @PreAuthorize("@ss.hasPermi('ywx:medicalrecord:edit')")
    @Log(title = "病历模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorMedicalrecord doctorMedicalrecord)
    {
        return toAjax(doctorMedicalrecordService.updateDoctorMedicalrecord(doctorMedicalrecord));
    }

    /**
     * 删除病历模版
     */
    @PreAuthorize("@ss.hasPermi('ywx:medicalrecord:remove')")
    @Log(title = "病历模版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorMedicalrecordService.deleteDoctorMedicalrecordByIds(ids));
    }
}
